import { MenuItemDefinition } from '@amcax/base';
import { PRODUCT_EVENT } from '@app-cad/common/Constants';
import { userEvents } from '@app-cad/module';
import { ProductTreeNode } from '../../types';

export const exchange: MenuItemDefinition<ProductTreeNode> = {
  id: 'exchange',
  children: '替换零部件',
  hidden: ({ data, props: { parent, type } }) =>
    parent !== data.docTree || !['product', 'part'].includes(type),
  onClick: ({ props: node }) => {
    userEvents.emit(PRODUCT_EVENT.ASSEMBLY_PRODUCT_EXCHANG, node);
  },
};
